﻿<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Uc_main_system_list.ascx.vb"
    Inherits="Apps_Shares_Uc_main_system_list" %>
<%--==============================BEGIN Filter==============================--%>
<table width="60%" border="1" align="center" cellpadding="2" cellspacing="2" bordercolor="#999999">
    <tr align="center" bgcolor="#99FFFF">
        <td colspan="2" bgcolor="#FFFFFF" class="th_data">
            ค้นหาข้อมูล
        </td>
    </tr>
    <tr align="left">
        <td width="47%" bordercolor="#CCCCCC" class="td_box">
            ชื่อระบบ :
        </td>
        <td width="53%" bordercolor="#CCCCCC" class="td_box">
            <asp:TextBox ID='txtSystemName' runat='server'></asp:TextBox>
        </td>
    </tr>
    <tr align="left">
        <td width="47%" bordercolor="#CCCCCC" class="td_box">
            ประเภทของระบบ :
        </td>
        <td width="53%" bordercolor="#CCCCCC" class="td_box">
            <asp:DropDownList ID='ddlSystemCategory' runat='server'>
                <asp:ListItem Text='ประเภท' Value='0'></asp:ListItem>
                <asp:ListItem Text='ข้อมูลหลักของระบบ' Value='1'></asp:ListItem>
                <asp:ListItem Text='ข้อมูลปฏิบัติงาน' Value='2'></asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>
    <tr align="left">
        <td width="47%" bordercolor="#CCCCCC" class="td_box">
            สถานะ :
        </td>
        <td width="53%" bordercolor="#CCCCCC" class="td_box">
            <asp:DropDownList ID='ddlStatus' runat="server">
                <asp:ListItem Text='สถานะ' Value='0'></asp:ListItem>
                <asp:ListItem Text='ใช้งาน' Value='1'></asp:ListItem>
                <asp:ListItem Text='ไม่ใช้งาน' Value='2'></asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>
    <tr align="center">
        <td colspan="2" bordercolor="#CCCCCC" class="td_data_end">
            <asp:Button ID='btnFilter' Text='<%$ Resources:Resource,BTN_SEARCH %>' runat='server' />
            <asp:Button ID='btnMainMenu' Text='<%$ Resources:Resource,BTN_MAINMENU %>' runat='server'
                PostBackUrl="~/Apps/ViewSystem.aspx?Edit=2" />
        </td>
    </tr>
</table>
<%--==============================END Filter==============================--%>
<div style="margin:5px;display:block;width:100%">&nbsp;</div>
<%--==============================BEGIN Display==============================--%>
<span class='component_caption'><asp:Literal ID='ltrCountView' runat='server' Text=''></asp:Literal></span>
<asp:ListView ID="gvDisplay" runat="server" DataSourceID="gvDisplaySrc" DataKeyNames='main_system_code'
    EnableModelValidation="True">
    <LayoutTemplate>
        <table cellspacing="2" cellpadding="2" bordercolor="#999999" border="0" align="center"
            width="100%">
            <tbody>
                <tr bgcolor="#ff9999" align="center">
                    <td bgcolor="#ffffff" class="th_data">
                        <asp:Image ID="main_system_name" runat="server" Visible="false" />
                        <asp:LinkButton ID='sort2' runat='server' CommandName='Sort' CommandArgument='main_system_name'>
                                ชื่อระบบ
                        </asp:LinkButton>
                    </td>
                    <td bgcolor="#ffffff" class="th_data">
                        <asp:Image ID="main_system_type_label" runat="server" Visible="false" />
                        <asp:LinkButton ID='sort3' runat='server' CommandName='Sort' CommandArgument='main_system_type_label'>
                                ประเภทของระบบ
                        </asp:LinkButton>
                    </td>
                    <td bgcolor="#ffffff" class="th_data">
                        <asp:Image ID="status" runat="server" Visible="false" />
                        <asp:LinkButton ID='sort4' runat='server' CommandName='Sort' CommandArgument='status'>
                                สถานะ
                        </asp:LinkButton>
                    </td>
                    <td bgcolor="#ffffff" class="th_data col_delete">
                        <input id='icbHeader' type='checkbox' />ลบข้อมูล
                    </td>
                </tr>
                <asp:PlaceHolder ID='itemPlaceholder' runat='server' />
                <tr bgcolor="#ff9999" align="center">
                    <td bgcolor="#ffffff" class="td_data_end" colspan="3">
                        <%-- ====================== Data Pager ======================--%>
                        <asp:DataPager ID="paging" runat="server" PagedControlID="gvDisplay" PageSize='10'>
                            <Fields>
                                <asp:NextPreviousPagerField ShowFirstPageButton="true" ShowLastPageButton="false"
                                    ShowNextPageButton='false' ShowPreviousPageButton='false' FirstPageText='<<' />
                                <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="false"
                                    ShowNextPageButton='false' ShowPreviousPageButton='true' PreviousPageText='<' />
                                <asp:NumericPagerField />
                                <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="false"
                                    ShowNextPageButton='true' ShowPreviousPageButton='false' NextPageText='>' />
                                <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="true"
                                    ShowNextPageButton='false' ShowPreviousPageButton='false' LastPageText='>>' />
                            </Fields>
                        </asp:DataPager>
                        <%-- ====================== Data Pager ======================--%>
                    </td>
                    <td bgcolor="#ffffff" class="td_data_end col_delete">
                        <asp:Button ID='btnDelete' runat='server' Text='ลบข้อมูล' OnClick='btnDelete_Click'
                            OnClientClick='<%$Resources:Resource,SCRIPT_CONFIRM_DELETE %>' />
                    </td>
                </tr>
            </tbody>
        </table>
    </LayoutTemplate>
    <EmptyDataTemplate>
        <br />
        <span class='star'>
            <center>
                ไม่พบข้อมูล</center>
        </span>
    </EmptyDataTemplate>
    <ItemTemplate>
        <tr >
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                <a href='<%# "main_system_fv.aspx?Edit=" & Eval("main_system_code") & CodeMatrix.Business.GenericData.GetViewMode() %>'>
                    <%# Eval("main_system_name")%>
                </a>
            </td>
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                <%# Eval("main_system_type_label")%>
            </td>
            <td align="center" class="td_data f_status" bordercolor="#CCCCCC">
                <%# Eval("status")%>
            </td>
            <td align="center" class="td_data col_delete" bordercolor="#CCCCCC">
                <asp:CheckBox ID='icbItem' runat='server' />
            </td>
        </tr>
    </ItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="gvDisplaySrc" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
        SelectCommand="
            select	main_system_code ,
		            main_system_name ,
		            main_system_type_label = case main_system_type
			            when 1 then 'ข้อมูลหลักของระบบ'
			            when 2 then 'ข้อมูลปฏิบัติงาน'
			            else 'N/A'
		            end ,
		            [status] = case main_system_status 
			            when 1 then 'ใช้งาน'
			            when 2 then 'ไม่ใช้งาน'
			            else 'N/A'
		            end , SeqNo = ROW_NUMBER() over(order by main_system_code)
            from	stp_main_system
            where	@status in (0,main_system_status) and
		            main_system_name like '%' + @main_system_name + '%' and
		            @main_system_type in (0,main_system_type) and main_system_type > 0"    
        DeleteCommand="EXEC  [dbo].[USP_GenericDelete] @tbl,@pid,@cid" >
    <DeleteParameters>
        <asp:Parameter DefaultValue="stp_main_system" Name="tbl" Type="String" />
        <asp:Parameter DefaultValue="main_system_code" Name="pid" Type="String" />
        <asp:Parameter DefaultValue="" Name="cid" Type="String" />
    </DeleteParameters>
    <SelectParameters>
        <asp:ControlParameter ControlID="ddlStatus" Name="status" 
            PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="txtSystemName" 
            ConvertEmptyStringToNull="False" Name="main_system_name" PropertyName="Text" />
        <asp:ControlParameter ControlID="ddlSystemCategory" Name="main_system_type" 
            PropertyName="SelectedValue" />
    </SelectParameters>
</asp:SqlDataSource>
<%--==============================END Display==============================--%>
<%--==============================To mark all check box==============================--%>
<script type="text/javascript">
    matchTableCheckBox('icbHeader', 'icbItem');
    hideDeleteColumn();
    hilightInactive();
</script>

